package com.nit.bike.utils;

/**
 * 隐私信息打码工具
 */
public class MaskUtil {
    /**
     * 手机号打码
     */
    public static String phoneMask(String phoneNumber) {
        if (phoneNumber == null || phoneNumber.length() < 11) {
            return null;
        }
        return phoneNumber.substring(0, 3) + "****" + phoneNumber.substring(phoneNumber.length() - 4);
    }

    /**
     * 身份证号打码
     */
    public static String idCardMask(String idCard) {
        if (idCard == null || idCard.length() < 15) {
            return null;
        }
        return idCard.substring(0, 3) + "****" + idCard.substring(idCard.length() - 4);
    }

    public static void main(String[] args) {
        System.out.println(phoneMask("12345678901"));
        System.out.println(idCardMask("333333222211113333"));
    }
}
